package com.tailyou.androidlearning202400;

import android.graphics.Color;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class JDLoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_login_jd);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        TextView tvAgree = findViewById(R.id.tvAgree);
        // 设置部分文字显示不同颜色
        SpannableString ss = new SpannableString("我已阅读并同意《京东隐私政策》《京东用户服务协议》未注册的手机号将自动创建京东账号");
        ss.setSpan(new ForegroundColorSpan(Color.parseColor("#0E8BAF")), 7, 15, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        ss.setSpan(new ForegroundColorSpan(Color.parseColor("#0E8BAF")), 15, 25, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        tvAgree.setText(ss);
    }
}